defmodule Ziply.Links do
  use Ecto.Schema

  import Ecto.Changeset

  @primary_key {:id, :id, autogenerate: false}
  schema "links" do
    field :hashid, :string
    field :orig_url, :string
    field :touch, :integer, default: 0
    field :del, :boolean, default: false

    timestamps(type: :utc_datetime_usec)
  end

  def changeset(links, attrs) do
    links
    |> cast(attrs, [:id, 
                  :hashid, 
                  :orig_url
                  ])
    |> validate_required([:hashid, :orig_url])
  end

end
